#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int T;
int n,m,L,V;
long long tot=1;
int d[N],v[N],a[N],c[N];
int l[N],r[N];
/*struct z{
    int l=-1,r=-1;
}e[N];*/
long long cnt;
long long ans;
int getv(int x){
    return abs((V*V-v[x]*v[x]))/(2*a[x]);
}
/*bool cmp(z p,z q){
    if(p.r==q.r){
        return p.l>q.l;
    }else{
        return p.r>q.r;
    }
}*/
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        ans=0;
        cnt=0;
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(c,0,sizeof(c));
        memset(l,-1,sizeof(l));
        memset(r,-1,sizeof(r));
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            int r;
            cin>>r;
            L=max(r,L);
            c[r]++;
        }
        while(c[L]==0){
            L--;
        }
        for(int i=1;i<=n;i++){
            //cout<<"@"<<i<<endl;
            if(a[i]==0){
                //cout<<"#1"<<endl;
                if(v[i]>V){
                    //cout<<"#11"<<endl;
                    cnt++;
                    ans=1;//left only one;
                }
                continue;
            }else if(a[i]<0){
                if(v[i]<=V){
                    //cout<<"#2"<<endl;
                    continue;
                }
                long long s=getv(i);
                for(int j=d[j];j<=d[j]+s;j++){
                    if(c[j]==1&&l[tot]==-1){
                        //e[tot].l=j;
                        l[tot]=j;
                    }
                    if(c[j]==1){
                        //cout<<"#3"<<endl;
                        r[tot]=max(j,r[tot]);
                    }
                    //cout<<"#33"<<endl;
                }
                if(l[tot]==-1&&r[tot]==-1){
                    tot--;
                }
                tot++;
            }else{
                long long s=getv(i);
                if(s>d[i]+L){
                    //cout<<"#4"<<endl;
                    continue;
                }
                for(int j=d[j];j<=d[j]+s;j++){
                    if(c[j]==1&&l[tot]==-1){
                        l[tot]=j;
                        continue;
                    }
                    if(c[j]==1){
                        r[tot]=min(j,L);
                    }
                }

                if(l[tot]==-1&&r[tot]==-1){
                    //cout<<"#4"<<endl;
                    tot--;
                }
                tot++;
                //cout<<"#44"<<endl;
            }
        }
        //sort(e+1,e+tot+1,cmp);
        for(int i=1;i<=tot;i++){
            cnt++;
            ans=cnt;
            /*for(int j=i;j<=n;j++){
                if(r[i]<r[j]){
                    swap(r[i],r[j]);
                    swap(l[i],l[j]);
                }else if(r[i]==r[j]){
                    swap(r[i],r[j]);
                    swap(l[i],l[j]);
                }
            }
            //for(int )
        }
        for(int i=1;i<tot;i++){
            cout<<l[i]<<" "<<r[i]<<endl;
        }*/}
        cout<<cnt<<" "<<m-ans<<endl;
    }
    return 0;
}
